package com.koushikdutta.async;

import com.koushikdutta.async.callback.DataCallback;

public class LineEmitter implements DataCallback {
    static final /* synthetic */ boolean $assertionsDisabled = (!LineEmitter.class.desiredAssertionStatus());
    StringBuilder data = new StringBuilder();
    StringCallback mLineCallback;

    public interface StringCallback {
        void onStringAvailable(String str);
    }

    public void setLineCallback(StringCallback callback) {
        this.mLineCallback = callback;
    }

    public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
        while (bb.remaining() > 0) {
            byte b = bb.get();
            if (b != (byte) 10) {
                this.data.append((char) b);
            } else if ($assertionsDisabled || this.mLineCallback != null) {
                this.mLineCallback.onStringAvailable(this.data.toString());
                this.data = new StringBuilder();
                return;
            } else {
                throw new AssertionError();
            }
        }
    }
}
